package com.test;

import com.auth0.jwt.interfaces.DecodedJWT;

import java.util.HashMap;
import java.util.Map;

public class Demo02 {
    public static void main(String[] args) {
        //获取token
        /*Map<String, String> map = new HashMap<>();
        map.put("username", "tom");
        map.put("userid", "12");
        String token = JwtUtils.getToken(map);
        System.out.println(token);*/
        //eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjgxNTg1NDYsInVzZXJpZCI6IjEyIiwidXNlcm5hbWUiOiJ0b20ifQ.fu5OfWuYbQUxfTorKpx4t8qpOYuiKOiPT6pJo-rHPb0

        //验证token
        /*boolean flag = JwtUtils.verify("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjgxNTg1NDYsInVzZXJpZCI6IjEyIiwidXNlcm5hbWUiOiJ0b20ifQ.fu5OfWuYbQUxfTorKpx4t8qpOYuiKOiPT6pJo-rHPb0");
        System.out.println(flag);*/

        //解析token
        DecodedJWT decodedJWT = JwtUtils.resolverToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2NjgxNTg3NDYsInVzZXJpZCI6IjEyIiwidXNlcm5hbWUiOiJ0b20ifQ.u0sclU5hxcLCDO32Z4rc3Ro7WZ-QiUkj2xlT3PEi6dw");
        String username = decodedJWT.getClaim("username").asString();
        System.out.println(username);
        System.out.println("aa");
    }
}
